﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinSCP;
using EFFC.Net.Parameters;

namespace EFFC.Net.ResourceLib.Parameters
{
    /// <summary>
    /// SFTP參數模板
    /// </summary>
    [Serializable]
    public class SFTPParameter:ParametersStd
    {
        public SFTPParameter()
        {
            AddPElement("HostName");
            AddPElement("ServerPort", typeof(int));
            AddPElement("_Protocol", typeof(Protocol));
            AddPElement("UserName");
            AddPElement("Password");
            AddPElement("SSHHostKey");
            AddPElement("_TransferMode", typeof(TransferMode));
            AddPElement("WinscpExePath");
            AddPElement("RemotePath");
            AddPElement("LocalPath");
            AddPElement("IsRemoveSourceFile", typeof(bool));

            SetValue("ServerPort", 22);
            SetValue("_Protocol", Protocol.Sftp);
            SetValue("_TransferMode", TransferMode.Binary);
            SetValue("IsRemoveSourceFile", false);
        }

        /// <summary>
        /// 服務器IP或URI名稱
        /// </summary>
        public string HostName
        {
            get { return GetValue<string>("HostName"); }
            set { SetValue("HostName", value); }
        }
        /// <summary>
        /// 服務器訪問端口，默認為22
        /// </summary>
        public int ServerPort
        {
            get { return GetValue<int>("ServerPort"); }
            set { SetValue("ServerPort", value); }
        }
        /// <summary>
        /// 傳輸協議，默認為FTP
        /// </summary>
        public Protocol Protocol
        {
            get { return GetValue<Protocol>("_Protocol"); }
            set { SetValue("_Protocol", value); }
        }
        /// <summary>
        /// 訪問帳號
        /// </summary>
        public string UserName
        {
            get { return GetValue<string>("UserName"); }
            set { SetValue("UserName", value); }
        }
        /// <summary>
        /// 訪問密碼
        /// </summary>
        public string Password
        {
            get { return GetValue<string>("Password"); }
            set { SetValue("Password", value); }
        }
        /// <summary>
        /// HostKey，格式：ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
        /// </summary>
        public string SSHHostKey
        {
            get { return GetValue<string>("SSHHostKey"); }
            set { SetValue("SSHHostKey", value); }
        }
        /// <summary>
        /// 傳送模式，默認為Binary
        /// </summary>
        public TransferMode TransferMode
        {
            get { return GetValue<TransferMode>("_TransferMode"); }
            set { SetValue("_TransferMode", value); }
        }
        /// <summary>
        /// Winscp.exe所在路徑，不捨則默認從工程目錄中找
        /// </summary>
        public string WinscpExePath
        {
            get { return GetValue<string>("WinscpExePath"); }
            set { SetValue("WinscpExePath", value); }
        }
        /// <summary>
        /// 遠端文件目錄或文件路徑
        /// </summary>
        public string RemotePath
        {
            get { return GetValue<string>("RemotePath"); }
            set { SetValue("RemotePath", value); }
        }
        /// <summary>
        /// 本地文件路徑或目錄
        /// </summary>
        public string LocalPath
        {
            get { return GetValue<string>("LocalPath"); }
            set { SetValue("LocalPath", value); }
        }
        /// <summary>
        /// 任務執行完成后是否移除原文件
        /// </summary>
        public bool IsRemoveSourceFile
        {
            get { return GetValue<bool>("IsRemoveSourceFile"); }
            set { SetValue("IsRemoveSourceFile", value); }
        }
    }
}
